package com.ykq.controller;

import com.ykq.entity.Emp;
import com.ykq.service.EmpService;
import com.ykq.util.CommonResult;
import com.ykq.util.TableLayUi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @program: 145ssm
 * @description:
 * @author: 闫克起2
 * @create: 2021-12-09 11:35
 **/
@Controller  //别忘记该注解
@RequestMapping("/emp")
public class EmpController {
    @Autowired  //别忘记该注解: spring容器注入该对象
    private EmpService empService;
    @RequestMapping("/list")
    @ResponseBody
    public List<Emp> list(){
        int c=10/0;
        List<Emp> all = empService.findAll();
        return all;
    }

    @RequestMapping("/listByCondition")
    @ResponseBody
    public TableLayUi listByCondition(int page,int limit,String empName,String email,String did){
          return empService.findEmpByCondition(page,limit,empName,email,did);
    }

    @RequestMapping("update")
    @ResponseBody
    public CommonResult update(Emp emp){
          System.out.println(emp);
         return empService.update(emp);
    }
}
